<template>
  <div class="div">
    <a-modal
      title="选择机构"
      :width="modalWidth"
      :visible="visible"
      :confirmLoading="confirmLoading"
      @ok="handleCancel"
      @cancel="handleCancel"
    >
      <a-spin tip="Loading..." :spinning="false">
        <a-table :columns="columns" :data-source="data">
          <span slot="action" slot-scope="text, record">
            <a @click="add(record)">选择</a>
          </span>
        </a-table>
      </a-spin>
    </a-modal>
  </div>
</template>
<script>
import { gkakJiGouManageData } from '@/api/api'
export default {
  name: 'JSelectDepartModal',
  props: ['modalWidth', 'multi', 'rootOpened', 'departId'],
  data() {
    return {
      visible: false,
      confirmLoading: false,
      // treeData: [],
      // autoExpandParent: true,
      // expandedKeys: [],
      // dataList: [],
      // checkedKeys: [],
      // checkedRows: [],
      // searchValue: '',
      data: [],
       columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'名称',
            align:"center",
            dataIndex: 'mingCheng'
          },
          {
            title:'等级',
            align:"center",
            dataIndex: 'dengJi_dictText'
          },
          {
            title:'联系人',
            align:"center",
            dataIndex: 'lianXiRen'
          },
          {
            title:'地区',
            align:"center",
            dataIndex: 'diQv'
          },
          {
            title:'经度',
            align:"center",
            dataIndex: 'jingDu'
          },
          {
            title:'维度',
            align:"center",
            dataIndex: 'weiDu'
          },
          {
            title:'网格码',
            align:"center",
            dataIndex: 'wangGeMaId'
          },
          {
            title:'机构类型',
            align:"center",
            dataIndex: 'type_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
    }
  },
  created() {
    this.loadDepart()
  },
  watch: {
   
  },
  methods: {
    show() {
      this.visible = true
     
    },
    loadDepart() {
      gkakJiGouManageData().then((res) => {
        
        if (res.success) {
          this.data = res.result.records
        
        }
      })
    },

    handleCancel() {
      this.visible = false
    },
  
    // 选择机构
    add(val){
      console.log(val.id)
        this.$emit('ok', val)
        this.visible = false
    }
  },
}
</script>

<style scoped>
.ant-modal-wrap >>> .ant-modal {
  width: 1200px !important;
}
</style>